package com.shop.service.impl;

import com.shop.dao.UserGroupDao;
import com.shop.entity.UserGroup;
import com.shop.service.UserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserGroupServiceImpl implements UserGroupService {
    @Autowired
    private UserGroupDao userGroupDao;

    @Override
    public UserGroup findById(int id) {
        return userGroupDao.getOne(id);
    }

    @Override
    public Page<UserGroup> findAll(Pageable pageable) {
        return userGroupDao.findAll(pageable);
    }


    @Override
    public List<UserGroup> findAllExample(Example<UserGroup> example) {
        return userGroupDao.findAll(example);
    }

    @Override
    public void update(UserGroup userGroup) {
        userGroupDao.save(userGroup);
    }

    @Override
    public void create(UserGroup userGroup) {
        userGroupDao.save(userGroup);
    }

    @Override
    public void delById(int id) {
        userGroupDao.delete(id);
    }

    @Override
    public List<UserGroup> findByUsername(String username) {
        return userGroupDao.findByUsername(username);
    }

}
